package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

@Controller
@SuppressWarnings("all")
public class OrderController {
    @Autowired
    private OrderFeignClient orderFeignClient;

    @GetMapping("trade.html")
    public String trade(Model model){
        Result<Map<String, Object>> result = orderFeignClient.trade();
        model.addAllAttributes(result.getData());
        /**
         * model.addAllAttributes(result.getData());
         * 相当于加入多个k,v
         * 不用一个一个加了(上边这一句代码代替了一遍这五行代码)
         *          Map<String, Object> data = result.getData();
         *         model.addAttribute("userAddressList",data.get("userAddressList"));
         *         model.addAttribute("detailArrayList",data.get("detailArrayList"));
         *         model.addAttribute("totalNum",data.get("totalNum"));
         *         model.addAttribute("totalAmount",data.get("totalAmount"));
         */

        return "order/trade";
    }
}
